#include "GameScene.h"

GameScene::GameScene()
{
    std::ifstream fichier("gen1.fdf", std::ios::in);
    float x = 0.0;
    float y = 0.0;
    std::string ligne;
    while(getline(fichier,ligne))
    {
        y = 0.0;
        while (ligne.find(" ") != std::string::npos)
        {
            std::string alt = ligne.substr(0, ligne.find(" "));
            float altint = atoi(alt.c_str());
             altint = altint / 190.0 * 0.190;
            vec3 pos(x, y, altint);
            if (altint < 0.01)
            {
                Cube* cu = new Cube(0,0,255,pos, 0.01);
                this->add(cu);
            }
            else if (altint < 0.100)
            {
                Cube *c = new Cube(0,255,0,pos, 0.01);
                this->add(c);
            }
            else if (altint < 0.160)
            {
                Cube *c = new Cube(127,127,127,pos, 0.01);
                this->add(c);
            }
            else if (altint <= 0.200)
            {
                Cube *c = new Cube(255,255,255,pos, 0.01);
                this->add(c);
            }
            ligne.erase(0, ligne.find(" ") + 1);
            y += 0.01;
        }
        x += 0.01;
    }
}

GameScene::~GameScene()
{
    //dtor
}
